/**
 * Created by JinMiao
 * 2017/7/5.
 */

fun main(args: Array<String>) {
    var father:Father=Son(1)
    if(father is Son){
        father.hi()
        father.absFunc()

    }
}

interface IInterface{
    fun hii()


}
//抽象类
abstract class Father(var a:Int):IInterface{
    //抽象方法
    abstract fun absFunc()

    //open的方法才能被重写
    open fun say(){
        println("father say")
    }

}

class Son: Father {
    override fun hii() {
    }

    //constructor是构造方法 下面等于
//    Son(int a ){
//        super(a)
//    }
    constructor(a:Int):super(a)
    constructor(a: Int,str:String):super(a)
    constructor(a:Int,l:Long):super(a)

    //可以初始化默认值
    constructor(a:Int,b:Int=55):super(a)

    //实现抽象方法
    override fun absFunc() {
        println("absFunc")
    }
    //重写父类方法
    override fun say() {
        super.say()
        println("child say")
    }
    //实现接口方法
    fun hi(){
        println("hi")
    }
}